import { IServiceManager } from "../ioc/types";
import { ITerminalActivator } from "../terminals/types";
import { ActiveResourceService } from "./application/activeResource";
import { ApplicationEnvironment } from "./application/applicationEnvironment";
import { ApplicationShell } from "./application/applicationShell";
import { CommandManager } from "./application/commandManager";
import { DebugService } from "./application/debugService";
import { DocumentManager } from "./application/documentmanager";
import { Extensions } from "./application/extensions";
import { TerminalManager } from "./application/terminalManager";
import { IActiveResourceService, IApplicationEnvironment, IApplicationShell, ICommandManager, IDebugService, IDocumentManager, ITerminalManager, IWorkspaceService } from "./application/types";
import { WorkspaceService } from "./application/workspace";
import { ConfigurationService } from "./configuration/service";
import { EditorUtils } from "./editor";
import { ExperimentService } from "./experiments/service";
import { InterpreterPathService } from "./interpreterPathService";
import { BrowserService } from "./net/browser";
import { PersistentStateFactory } from "./persistentState";
import { PathUtils } from "./platform/pathUtils";
import { CurrentProcess } from "./process/currentProcess";
import { ProcessLogger } from "./process/logger";
import { IProcessLogger } from "./process/types";
import { TerminalActivator } from "./terminal/activator";
import { PowershellTerminalActivationFailedHandler } from "./terminal/activator/powershellFailedHandler";
import { Bash } from "./terminal/environmentActivationProviders/bash";
import { CondaActivationCommandProvider } from "./terminal/environmentActivationProviders/condaActivationProvider";
import { TerminalHelper } from "./terminal/helper";
import { SettingsShellDetector } from "./terminal/shellDetectors/settingsShellDetector";
import { TerminalNameShellDetector } from "./terminal/shellDetectors/terminalNameShellDetector";
import { IShellDetector, ITerminalActivationCommandProvider, ITerminalActivationHandler, ITerminalHelper, TerminalActivationProviders } from "./terminal/types";
import { IBrowserService, IConfigurationService, ICurrentProcess, IEditorUtils, IExperimentService, IExtensions, IInterpreterPathService, IPathUtils, IPersistentStateFactory, IRandom, IsWindows, IS_WINDOWS } from "./types";
import { IMultiStepInputFactory, MultiStepInputFactory } from "./utils/multiStepInput";
import { Random } from "./utils/random";

export function registerTypes(serviceManager: IServiceManager): void {
    serviceManager.addSingleton<IExperimentService>(IExperimentService, ExperimentService);
    serviceManager.addSingleton<IWorkspaceService>(IWorkspaceService, WorkspaceService);
    serviceManager.addSingleton<IApplicationEnvironment>(IApplicationEnvironment, ApplicationEnvironment);
    serviceManager.addSingleton<IPathUtils>(IPathUtils, PathUtils);
    serviceManager.addSingletonInstance<boolean>(IsWindows, IS_WINDOWS);
    serviceManager.addSingleton<ICurrentProcess>(ICurrentProcess, CurrentProcess);
    serviceManager.addSingleton<IPersistentStateFactory>(IPersistentStateFactory, PersistentStateFactory);
    serviceManager.addSingleton<ICommandManager>(ICommandManager, CommandManager);
    serviceManager.addSingleton<IConfigurationService>(IConfigurationService, ConfigurationService);
    serviceManager.addSingleton<IInterpreterPathService>(IInterpreterPathService, InterpreterPathService);
    serviceManager.addSingleton<IExtensions>(IExtensions, Extensions);
    serviceManager.addSingleton<IDocumentManager>(IDocumentManager, DocumentManager);
    serviceManager.addSingleton<IApplicationShell>(IApplicationShell, ApplicationShell);
    serviceManager.addSingleton<IBrowserService>(IBrowserService, BrowserService);
    serviceManager.addSingleton<IRandom>(IRandom, Random);
    serviceManager.addSingleton<IActiveResourceService>(IActiveResourceService, ActiveResourceService);
    serviceManager.addSingleton<IDebugService>(IDebugService, DebugService);
    serviceManager.addSingleton<ITerminalManager>(ITerminalManager, TerminalManager);
    serviceManager.addSingleton<ITerminalActivator>(ITerminalActivator, TerminalActivator);
    serviceManager.addSingleton<ITerminalHelper>(ITerminalHelper, TerminalHelper);
    serviceManager.addSingleton<ITerminalActivationCommandProvider>(
        ITerminalActivationCommandProvider,
        Bash,
        TerminalActivationProviders.bashCShellFish,
    );
    serviceManager.addSingleton<ITerminalActivationCommandProvider>(
        ITerminalActivationCommandProvider,
        CondaActivationCommandProvider,
        TerminalActivationProviders.conda,
    );
    serviceManager.addSingleton<IShellDetector>(IShellDetector, TerminalNameShellDetector);
    serviceManager.addSingleton<IShellDetector>(IShellDetector, SettingsShellDetector);
    // serviceManager.addSingleton<IShellDetector>(IShellDetector, UserEnvironmentShellDetector);
    // serviceManager.addSingleton<IShellDetector>(IShellDetector, VSCEnvironmentShellDetector);
    serviceManager.addSingleton<ITerminalActivationHandler>(
        ITerminalActivationHandler,
        PowershellTerminalActivationFailedHandler,
    );
    serviceManager.addSingleton<IProcessLogger>(IProcessLogger, ProcessLogger);
    serviceManager.addSingleton<IEditorUtils>(IEditorUtils, EditorUtils);
    serviceManager.addSingleton<IMultiStepInputFactory>(IMultiStepInputFactory, MultiStepInputFactory);
}

